home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gui4cli.lha
/
Gui4Cli
/
G4C
/
Rep.gc
< prev
next >
Wrap
Text File
|
1999-04-21
|
6KB
|
263 lines
G4C
; Rep.gc 1.3 (D.Kelesekis 29/9/97)
; =================================================================
; This is a GUI script for the "Rep" command, which replaces strings
; in text files.
; =================================================================
; The window & graphics
; =================================================================
WINBIG 121 11 415 189 'Replace - SYS:'
WinType 11110001 ; it's resizable & font sensitive with all gadgets
varpath ''
BOX 0 0 415 189 OUT button
BOX 210 28 195 77 in button
BOX 210 109 196 37 IN BUTTON
BOX 210 150 196 36 in button
CTEXT 219 30 "String:" #screen 8 2 0 "0001"
CTEXT 218 58 "To String:" #screen 8 2 0 "0001"
CTEXT 218 114 "Save to Dir:" #screen 8 2 0 "0001"
XICON 329 8 :rep.gc
ezreq 'REP 1.3 - October 1997\n\nBy D.Keletsekis\ndck@prometheus.hol.gr\n' 'My Hero!' ''
; =================================================================
; System events
; =================================================================
xOnLoad
from = ""
to = ""
todir = ram:
savetodir = ON
ci = ""
guiopen rep.gc
ifexists file c:rep
RUN 'resident c:Rep pure add'
elseifexists file guis:c/rep
RUN 'resident guis:c/Rep pure add'
else
extract rep.gc guipath path
joinfile $path rep path
ifexists file $path
RUN 'resident $path pure add'
else
ezreq 'REP was not found!' OK ''
endif
endif
; helper gui
ifexists file guis:tools/rtn/filepop
helper = 1 ; set flag to know we have it
else
helper = 0
endif
xOnClose
guiquit rep.gc
run 'resident rep remove'
; =================================================================
; The Directory listview
; =================================================================
XLISTVIEW 6 5 198 182 "" file SYS: 10 DIR
GadID 1
gadhelp 'Select files to act upon'
GadFont #mono 8 000
if $helper = 1
guiload guis:tools/rtn/filepop $rep.gc/file
endif
xlvdirhook 1
setwintitle rep.gc '$$lv.dir'
; =================================================================
; The listview's buttons
; =================================================================
XBUTTON 216 7 20 14 P
gadhelp 'CD to Parent dir'
lvuse rep.gc 1
lvdir parent
setwintitle rep.gc '$$lv.dir'
XBUTTON 237 7 20 14 D
gadhelp 'Show Device list'
lvuse rep.gc 1
lvdir disks
setwintitle rep.gc '$$lv.dir'
XBUTTON 261 7 20 14 A
gadhelp 'Select all items'
lvuse rep.gc 1
lvdir all
XBUTTON 282 7 21 14 N
gadhelp 'Unselect all items'
lvuse rep.gc 1
lvdir none
; =================================================================
; Settings - xTEXTIN & xCYCLER gadgets
; =================================================================
XTEXTIN 218 42 180 15 '' from "" 100 ; string to Rep
gadhelp 'Enter string to search for and replace'
gadid 30
setgad rep.gc 31 on ; goto next gadget
XTEXTIN 218 69 180 15 '' to "" 100 ; Rep with this
gadhelp 'Enter string with which to replace the above'
gadid 31
setgad rep.gc 30 on
XCYCLER 218 86 180 14 "" ci
gadhelp 'Search mode'
cstr "Case Sensitive" ""
cstr "Case Insensitive" I
; =================================================================
; Save to a different dir
; =================================================================
; --- Dir to save file in. If this is the same dir as the file being
; --- converted, then the file will be overwriten.
XCHECKBOX 372 115 26 11 "" savetodir ON OFF ON
gadhelp 'Check to copy altered files to other dir - Requester will open..'
if $savetodir == ON
setgad rep.gc 20 on
ReqFile -1 -1 300 200 "Choose destination:" DIR todir ram:
update rep.gc 20 $todir
else
setgad rep.gc 20 off
endif
XTEXTIN 218 127 180 15 '' todir "Ram:" 100
gadhelp 'Altered files will be copied to this dir'
gadid 20
; =================================================================
; Do it.
; =================================================================
XBUTTON 218 169 90 14 Start
gadhelp 'Start replacing'
gadid 100
; --- check that we have all the parameters we need
lvuse rep.gc 1
lvmulti first
if $file = ""
update rep.gc 2 "No file chosen."
stop
endif
if $from = ""
update rep.gc 2 'No "From" defined!'
stop
endif
if $to = ""
update rep.gc 2 'No "To" defined!'
stop
endif
; --- get dest dir, if defined, and make dest name..
destfile = ""
if $savetodir == ON
and $todir > " "
extract file FILE fname
dest = $todir
joinfile $dest $fname destfile
endif
update rep.gc 2 '$file'
; --- launch it..
setgad rep.gc 100 off
flag = 0
launch 5 'Rep $file $from $to $destfile $ci'
; --- Use of the launch command will allow the other GUIs running on
; --- this instance of Gui4Cli to go about their business normally
; --- Then when this file is finished ...
xOnReturn 5
; --- note our arrival..
update rep.gc 2 'OK - $file'
lvuse rep.gc 1
lvmulti OFF
; --- check if we've already been told to stop..
if $flag != 0
setgad rep.gc 100 on
stop
endif
; --- do next file
lvmulti next
if $file = "" ; no more files
if $todir > " "
lvdir #$todir
setwintitle rep.gc '$$lv.dir'
else
lvdir refresh
endif
setgad rep.gc 100 on
stop
endif
if $savetodir == ON
and $todir > " "
extract file FILE fname
dest = $todir
joinfile $dest $fname destfile
endif
update rep.gc 2 '$file'
launch 5 'Rep $file $from $to $destfile $ci'
; =================================================================
; Cancel & text display
; =================================================================
XBUTTON 308 169 90 14 Stop
gadhelp 'Abort replacing'
breaktask Rep C
setvar flag 1
xonfail ; everybody's human..
setgad rep.gc 100 on
update rep.gc 2 '** Error **'
; --- a text display, telling you what's going on.
TEXT 218 154 180 14 Waiting.. 100 BOX
gadid 2